<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class=" layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            <li>
                <a href="/OverView/jobFunction">Job Function</a>
            </li>
            <li class="layui-this">年龄段</li>
        </ul>
        <div class="layui-card-body">
            <table id="user-table" lay-filter="user-table"></table>
        </div>
    </div>
</div>

{include file="_Fragment/javascript" /}
<script>
    layui.use(['table', 'form', 'jquery','common'], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;

        let cols = [
            [{
                    title: '年龄段',
                    field: 'age',
                    align: 'center'
                },
                {
                    title: '学员数',
                    field: 'user_num',
                    align: 'center',
                    event: 'user',
                    style:'color: #1E9FFF'
                },
                {
                    title: '人均课程数',
                    field: 'average_course',
                    align: 'center'
                },
                {
                    title: '最大选课数',
                    field: 'max_course',
                    align: 'center',
                },
                {
                    title: '课程合集数',
                    field: 'collection',
                    align: 'center',
                    event: 'collection',
                    style:'color: #1E9FFF'
                },
                {
                    title: '人均可推荐课程数',
                    field: 'recommend_course',
                    align: 'center',
                },
                {
                    title: '最低可推荐课程数',
                    field: 'minimum_recommend_course',
                    align: 'center',
                }
            ]
        ]

        table.render({
            elem: '#user-table',
            url: '/OverView/getAgeList',
            page: {layout:['count', 'prev', 'page', 'next', 'skip']},
            limit: 10,
            cols: cols,
            //skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', {
                title: '提示' //标题
                ,layEvent: 'tips' //事件名，用于 toolbar 事件中使用
                ,icon: 'layui-icon-tips' //图标类名
            }]
        });

        table.on('tool(user-table)', function(obj) {
            if (obj.event === 'user') {
                window.user(obj);
            } else if (obj.event === 'collection') {
                window.collection(obj);
            }
        });


        table.on('toolbar(user-table)', function(obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'tips') {
                window.tips();
            }
        });


        window.tips = function() {
            layer.open({
                type: 1,
                title:'提示',
                shade: 0.1,
                area: [common.isModile()?'100%':'520px', common.isModile()?'100%':'240px'],
                content: '<div style="margin-bottom: 20px"><strong><i class="layui-icon layui-icon-rate"></i> 人均课程数：</strong>平均每人已注册的课程数量</div>\n' +
                    '<div style="margin-bottom: 20px"><strong><i class="layui-icon layui-icon-rate"></i> 最大选课数：</strong>该function下，已注册课程数量最多的员工的注册课程数</div>\n' +
                    '<div style="margin-bottom: 20px"><strong><i class="layui-icon layui-icon-rate"></i> 课程合集数：</strong>该function员工的所有已注册课程合集</div>\n'+
                    '<div style="margin-bottom: 20px"><strong><i class="layui-icon layui-icon-rate"></i> 人均可推荐课程数：</strong>课程合集数-人均课程数</div>\n'+
                    '<div style="margin-bottom: 20px"><strong><i class="layui-icon layui-icon-rate"></i> 最低可推荐课程数：</strong>课程合集数-最大选课数</div>'
            });
        };


        window.user = function(obj) {
            layer.open({
                type: 2,
                title: '学员详情',
                shade: 0.1,
                area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'],
                content: '/OverView/user?id='+obj.data.id+'&type=age'
            });
        }

        window.collection = function(obj) {
            layer.open({
                type: 2,
                title: '课程详情',
                shade: 0.1,
                area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'],
                content: '/OverView/collection?id='+obj.data.id+'&type=age'
            });
        }


        window.refresh = function(param) {
            table.reload('user-table');
        }
    })
</script>
</body>
</html>
